unit PXL.Windows.D3D10;
(*
 * This file is part of Asphyre Framework, also known as Platform eXtended Library (PXL).
 * Copyright (c) 2015 - 2017 Yuriy Kotsarenko. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the License.
 *)
{
  DirectX Headers translation by Yuriy Kotsarenko, August 2015. Revision 1.0.

  Translated DirectX C/C++ files:
    d3d10.h
    d3d10_1.h
    d3d10misc.h
    
  Original source code was taken from:
    %WINDOWS_KITS%\8.0\Include\um\
    %WINDOWS_KITS%\8.0\Include\shared\

  Note: portions of this file were translated using automated tool.
}
interface

{$IFDEF FPC}
  {$PACKRECORDS C}
  {$MODE DELPHI}
{$ELSE}
  {$ALIGN ON}
{$ENDIF}

uses
  Windows, PXL.Windows.D3DCommon, PXL.Windows.DXGI;

const
  D3D10_16BIT_INDEX_STRIP_CUT_VALUE = $FFFF;
  D3D10_32BIT_INDEX_STRIP_CUT_VALUE = $FFFFFFFF;
  D3D10_8BIT_INDEX_STRIP_CUT_VALUE = $FF;
  D3D10_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT = 9;
  D3D10_CLIP_OR_CULL_DISTANCE_COUNT = 8;
  D3D10_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT = 2;
  D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT = 14;
  D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS = 4;
  D3D10_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT = 32;
  D3D10_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT = 15;
  D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS = 4;
  D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT = 15;
  D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST = 1;
  D3D10_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS = 1;
  D3D10_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT = 64;
  D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS = 4;
  D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT = 1;
  D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST = 1;
  D3D10_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS = 1;
  D3D10_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT = 32;
  D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS = 1;
  D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT = 128;
  D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST = 1;
  D3D10_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS = 1;
  D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT = 128;
  D3D10_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS = 1;
  D3D10_COMMONSHADER_SAMPLER_REGISTER_COUNT = 16;
  D3D10_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST = 1;
  D3D10_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS = 1;
  D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT = 16;
  D3D10_COMMONSHADER_SUBROUTINE_NESTING_LIMIT = 32;
  D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENTS = 4;
  D3D10_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_COMMONSHADER_TEMP_REGISTER_COUNT = 4096;
  D3D10_COMMONSHADER_TEMP_REGISTER_READS_PER_INST = 3;
  D3D10_COMMONSHADER_TEMP_REGISTER_READ_PORTS = 3;
  D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX = 10;
  D3D10_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN = -10;
  D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE = -8;
  D3D10_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE = 7;
  D3D10_DEFAULT_BLEND_FACTOR_ALPHA = 1.0;
  D3D10_DEFAULT_BLEND_FACTOR_BLUE = 1.0;
  D3D10_DEFAULT_BLEND_FACTOR_GREEN = 1.0;
  D3D10_DEFAULT_BLEND_FACTOR_RED = 1.0;
  D3D10_DEFAULT_BORDER_COLOR_COMPONENT = 0.0;
  D3D10_DEFAULT_DEPTH_BIAS = 0;
  D3D10_DEFAULT_DEPTH_BIAS_CLAMP = 0.0;
  D3D10_DEFAULT_MAX_ANISOTROPY = 16.0;
  D3D10_DEFAULT_MIP_LOD_BIAS = 0.0;
  D3D10_DEFAULT_RENDER_TARGET_ARRAY_INDEX = 0;
  D3D10_DEFAULT_SAMPLE_MASK = $FFFFFFFF;
  D3D10_DEFAULT_SCISSOR_ENDX = 0;
  D3D10_DEFAULT_SCISSOR_ENDY = 0;
  D3D10_DEFAULT_SCISSOR_STARTX = 0;
  D3D10_DEFAULT_SCISSOR_STARTY = 0;
  D3D10_DEFAULT_SLOPE_SCALED_DEPTH_BIAS = 0.0;
  D3D10_DEFAULT_STENCIL_READ_MASK = $FF;
  D3D10_DEFAULT_STENCIL_REFERENCE = 0;
  D3D10_DEFAULT_STENCIL_WRITE_MASK = $FF;
  D3D10_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX = 0;
  D3D10_DEFAULT_VIEWPORT_HEIGHT = 0;
  D3D10_DEFAULT_VIEWPORT_MAX_DEPTH = 0.0;
  D3D10_DEFAULT_VIEWPORT_MIN_DEPTH = 0.0;
  D3D10_DEFAULT_VIEWPORT_TOPLEFTX = 0;
  D3D10_DEFAULT_VIEWPORT_TOPLEFTY = 0;
  D3D10_DEFAULT_VIEWPORT_WIDTH = 0;
  D3D10_FLOAT16_FUSED_TOLERANCE_IN_ULP = 0.6;
  D3D10_FLOAT32_MAX = 3.402823466E+38;
  D3D10_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP = 0.6;
  D3D10_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR = 2.4;
  D3D10_FLOAT_TO_SRGB_EXPONENT_NUMERATOR = 1.0;
  D3D10_FLOAT_TO_SRGB_OFFSET = 0.055;
  D3D10_FLOAT_TO_SRGB_SCALE_1 = 12.92;
  D3D10_FLOAT_TO_SRGB_SCALE_2 = 1.055;
  D3D10_FLOAT_TO_SRGB_THRESHOLD = 0.0031308;
  D3D10_FTOI_INSTRUCTION_MAX_INPUT = 2147483647.999;
  D3D10_FTOI_INSTRUCTION_MIN_INPUT = -2147483648.999;
  D3D10_FTOU_INSTRUCTION_MAX_INPUT = 4294967295.999;
  D3D10_FTOU_INSTRUCTION_MIN_INPUT = 0.0;
  D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS = 1;
  D3D10_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_GS_INPUT_PRIM_CONST_REGISTER_COUNT = 1;
  D3D10_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST = 2;
  D3D10_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS = 1;
  D3D10_GS_INPUT_REGISTER_COMPONENTS = 4;
  D3D10_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_GS_INPUT_REGISTER_COUNT = 16;
  D3D10_GS_INPUT_REGISTER_READS_PER_INST = 2;
  D3D10_GS_INPUT_REGISTER_READ_PORTS = 1;
  D3D10_GS_INPUT_REGISTER_VERTICES = 6;
  D3D10_GS_OUTPUT_ELEMENTS = 32;
  D3D10_GS_OUTPUT_REGISTER_COMPONENTS = 4;
  D3D10_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_GS_OUTPUT_REGISTER_COUNT = 32;
  D3D10_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES = 0;
  D3D10_IA_DEFAULT_PRIMITIVE_TOPOLOGY = 0;
  D3D10_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES = 0;
  D3D10_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT = 1;
  D3D10_IA_INSTANCE_ID_BIT_COUNT = 32;
  D3D10_IA_INTEGER_ARITHMETIC_BIT_COUNT = 32;
  D3D10_IA_PRIMITIVE_ID_BIT_COUNT = 32;
  D3D10_IA_VERTEX_ID_BIT_COUNT = 32;
  D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT = 16;
  D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS = 64;
  D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT = 16;
  D3D10_INTEGER_DIVIDE_BY_ZERO_QUOTIENT = $FFFFFFFF;
  D3D10_INTEGER_DIVIDE_BY_ZERO_REMAINDER = $FFFFFFFF;
  D3D10_LINEAR_GAMMA = 1.0;
  D3D10_MAX_BORDER_COLOR_COMPONENT = 1.0;
  D3D10_MAX_DEPTH = 1.0;
  D3D10_MAX_MAXANISOTROPY = 16;
  D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT = 32;
  D3D10_MAX_POSITION_VALUE = 3.402823466E+34;
  D3D10_MAX_TEXTURE_DIMENSION_2_TO_EXP = 17;
  D3D10_MIN_BORDER_COLOR_COMPONENT = 0.0;
  D3D10_MIN_DEPTH = 0.0;
  D3D10_MIN_MAXANISOTROPY = 0;
  D3D10_MIP_LOD_BIAS_MAX = 15.99;
  D3D10_MIP_LOD_BIAS_MIN = -16.0;
  D3D10_MIP_LOD_FRACTIONAL_BIT_COUNT = 6;
  D3D10_MIP_LOD_RANGE_BIT_COUNT = 8;
  D3D10_MULTISAMPLE_ANTIALIAS_LINE_WIDTH = 1.4;
  D3D10_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT = 0;
  D3D10_PIXEL_ADDRESS_RANGE_BIT_COUNT = 13;
  D3D10_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT = 15;
  D3D10_PS_FRONTFACING_DEFAULT_VALUE = $FFFFFFFF;
  D3D10_PS_FRONTFACING_FALSE_VALUE = 0;
  D3D10_PS_FRONTFACING_TRUE_VALUE = $FFFFFFFF;
  D3D10_PS_INPUT_REGISTER_COMPONENTS = 4;
  D3D10_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_PS_INPUT_REGISTER_COUNT = 32;
  D3D10_PS_INPUT_REGISTER_READS_PER_INST = 2;
  D3D10_PS_INPUT_REGISTER_READ_PORTS = 1;
  D3D10_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT = 0.0;
  D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS = 1;
  D3D10_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_PS_OUTPUT_DEPTH_REGISTER_COUNT = 1;
  D3D10_PS_OUTPUT_REGISTER_COMPONENTS = 4;
  D3D10_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_PS_OUTPUT_REGISTER_COUNT = 8;
  D3D10_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT = 0.5;
  D3D10_REQ_BLEND_OBJECT_COUNT_PER_CONTEXT = 4096;
  D3D10_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP = 27;
  D3D10_REQ_CONSTANT_BUFFER_ELEMENT_COUNT = 4096;
  D3D10_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_CONTEXT = 4096;
  D3D10_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP = 32;
  D3D10_REQ_DRAW_VERTEX_COUNT_2_TO_EXP = 32;
  D3D10_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION = 8192;
  D3D10_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT = 1024;
  D3D10_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT = 4096;
  D3D10_REQ_MAXANISOTROPY = 16;
  D3D10_REQ_MIP_LEVELS = 14;
  D3D10_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES = 2048;
  D3D10_REQ_RASTERIZER_OBJECT_COUNT_PER_CONTEXT = 4096;
  D3D10_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH = 8192;
  D3D10_REQ_RESOURCE_SIZE_IN_MEGABYTES = 128;
  D3D10_REQ_RESOURCE_VIEW_COUNT_PER_CONTEXT_2_TO_EXP = 20;
  D3D10_REQ_SAMPLER_OBJECT_COUNT_PER_CONTEXT = 4096;
  D3D10_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION = 512;
  D3D10_REQ_TEXTURE1D_U_DIMENSION = 8192;
  D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION = 512;
  D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION = 8192;
  D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION = 2048;
  D3D10_REQ_TEXTURECUBE_DIMENSION = 8192;
  D3D10_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL = 0;
  D3D10_SHADER_MAJOR_VERSION = 4;
  D3D10_SHADER_MINOR_VERSION = 0;
  D3D10_SHIFT_INSTRUCTION_PAD_VALUE = 0;
  D3D10_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT = 5;
  D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT = 8;
  D3D10_SO_BUFFER_MAX_STRIDE_IN_BYTES = 2048;
  D3D10_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES = 256;
  D3D10_SO_BUFFER_SLOT_COUNT = 4;
  D3D10_SO_DDI_REGISTER_INDEX_DENOTING_GAP = $FFFFFFFF;
  D3D10_SO_MULTIPLE_BUFFER_ELEMENTS_PER_BUFFER = 1;
  D3D10_SO_SINGLE_BUFFER_COMPONENT_LIMIT = 64;
  D3D10_SRGB_GAMMA = 2.2;
  D3D10_SRGB_TO_FLOAT_DENOMINATOR_1 = 12.92;
  D3D10_SRGB_TO_FLOAT_DENOMINATOR_2 = 1.055;
  D3D10_SRGB_TO_FLOAT_EXPONENT = 2.4;
  D3D10_SRGB_TO_FLOAT_OFFSET = 0.055;
  D3D10_SRGB_TO_FLOAT_THRESHOLD = 0.04045;
  D3D10_SRGB_TO_FLOAT_TOLERANCE_IN_ULP = 0.5;
  D3D10_STANDARD_COMPONENT_BIT_COUNT = 32;
  D3D10_STANDARD_COMPONENT_BIT_COUNT_DOUBLED = 64;
  D3D10_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE = 4;
  D3D10_STANDARD_PIXEL_COMPONENT_COUNT = 128;
  D3D10_STANDARD_PIXEL_ELEMENT_COUNT = 32;
  D3D10_STANDARD_VECTOR_SIZE = 4;
  D3D10_STANDARD_VERTEX_ELEMENT_COUNT = 16;
  D3D10_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT = 64;
  D3D10_SUBPIXEL_FRACTIONAL_BIT_COUNT = 8;
  D3D10_SUBTEXEL_FRACTIONAL_BIT_COUNT = 6;
  D3D10_TEXEL_ADDRESS_RANGE_BIT_COUNT = 18;
  D3D10_UNBOUND_MEMORY_ACCESS_RESULT = 0;
  D3D10_VIEWPORT_AND_SCISSORRECT_MAX_INDEX = 15;
  D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE = 16;
  D3D10_VIEWPORT_BOUNDS_MAX = 16383;
  D3D10_VIEWPORT_BOUNDS_MIN = -16384;
  D3D10_VS_INPUT_REGISTER_COMPONENTS = 4;
  D3D10_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_VS_INPUT_REGISTER_COUNT = 16;
  D3D10_VS_INPUT_REGISTER_READS_PER_INST = 2;
  D3D10_VS_INPUT_REGISTER_READ_PORTS = 1;
  D3D10_VS_OUTPUT_REGISTER_COMPONENTS = 4;
  D3D10_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_VS_OUTPUT_REGISTER_COUNT = 16;
  D3D10_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT = 10;
  D3D10_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP = 25;
  D3D10_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP = 25;
  D3D_MAJOR_VERSION = 10;
  D3D_MINOR_VERSION = 0;
  D3D_SPEC_DATE_DAY = 8;
  D3D_SPEC_DATE_MONTH = 8;
  D3D_SPEC_DATE_YEAR = 2006;
  D3D_SPEC_VERSION = 1.050005;
  D3D10_1_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT = D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT;
  D3D10_1_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT = D3D10_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT;
  D3D10_APPEND_ALIGNED_ELEMENT = $FFFFFFFF;
  D3D10_FILTER_TYPE_MASK = $3;
  D3D10_MIN_FILTER_SHIFT = 4;
  D3D10_MAG_FILTER_SHIFT = 2;
  D3D10_MIP_FILTER_SHIFT = 0;
  D3D10_COMPARISON_FILTERING_BIT = $80;
  D3D10_ANISOTROPIC_FILTERING_BIT = $40;
  D3D10_TEXT_1BIT_BIT = $80000000;
  D3D10_SDK_VERSION = 29;
  D3D10_1_DEFAULT_SAMPLE_MASK = $FFFFFFFF;
  D3D10_1_FLOAT16_FUSED_TOLERANCE_IN_ULP = 0.6;
  D3D10_1_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP = 0.6;
  D3D10_1_GS_INPUT_REGISTER_COUNT = 32;
  D3D10_1_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS = 128;
  D3D10_1_PS_OUTPUT_MASK_REGISTER_COMPONENTS = 1;
  D3D10_1_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT = 32;
  D3D10_1_PS_OUTPUT_MASK_REGISTER_COUNT = 1;
  D3D10_1_SHADER_MAJOR_VERSION = 4;
  D3D10_1_SHADER_MINOR_VERSION = 1;
  D3D10_1_SO_BUFFER_MAX_STRIDE_IN_BYTES = 2048;
  D3D10_1_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES = 256;
  D3D10_1_SO_BUFFER_SLOT_COUNT = 4;
  D3D10_1_SO_MULTIPLE_BUFFER_ELEMENTS_PER_BUFFER = 1;
  D3D10_1_SO_SINGLE_BUFFER_COMPONENT_LIMIT = 64;
  D3D10_1_STANDARD_VERTEX_ELEMENT_COUNT = 32;
  D3D10_1_SUBPIXEL_FRACTIONAL_BIT_COUNT = 8;
  D3D10_1_VS_INPUT_REGISTER_COUNT = 32;
  D3D10_1_VS_OUTPUT_REGISTER_COUNT = 32;
  D3D10_1_SDK_VERSION = (0 + $20);

  D3D10_INPUT_PER_VERTEX_DATA = 0;
  D3D10_INPUT_PER_INSTANCE_DATA = 1;

  D3D10_FILL_WIREFRAME = 2;
  D3D10_FILL_SOLID = 3;

  D3D10_CULL_NONE = 1;
  D3D10_CULL_FRONT = 2;
  D3D10_CULL_BACK = 3;

  D3D10_RESOURCE_DIMENSION_UNKNOWN = 0;
  D3D10_RESOURCE_DIMENSION_BUFFER = 1;
  D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2;
  D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3;
  D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4;

  D3D10_DSV_DIMENSION_UNKNOWN = 0;
  D3D10_DSV_DIMENSION_TEXTURE1D = 1;
  D3D10_DSV_DIMENSION_TEXTURE1DARRAY = 2;
  D3D10_DSV_DIMENSION_TEXTURE2D = 3;
  D3D10_DSV_DIMENSION_TEXTURE2DARRAY = 4;
  D3D10_DSV_DIMENSION_TEXTURE2DMS = 5;
  D3D10_DSV_DIMENSION_TEXTURE2DMSARRAY = 6;

  D3D10_RTV_DIMENSION_UNKNOWN = 0;
  D3D10_RTV_DIMENSION_BUFFER = 1;
  D3D10_RTV_DIMENSION_TEXTURE1D = 2;
  D3D10_RTV_DIMENSION_TEXTURE1DARRAY = 3;
  D3D10_RTV_DIMENSION_TEXTURE2D = 4;
  D3D10_RTV_DIMENSION_TEXTURE2DARRAY = 5;
  D3D10_RTV_DIMENSION_TEXTURE2DMS = 6;
  D3D10_RTV_DIMENSION_TEXTURE2DMSARRAY = 7;
  D3D10_RTV_DIMENSION_TEXTURE3D = 8;

  D3D10_USAGE_DEFAULT = 0;
  D3D10_USAGE_IMMUTABLE = 1;
  D3D10_USAGE_DYNAMIC = 2;
  D3D10_USAGE_STAGING = 3;

  D3D10_BIND_VERTEX_BUFFER = $1;
  D3D10_BIND_INDEX_BUFFER = $2;
  D3D10_BIND_CONSTANT_BUFFER = $4;
  D3D10_BIND_SHADER_RESOURCE = $8;
  D3D10_BIND_STREAM_OUTPUT = $10;
  D3D10_BIND_RENDER_TARGET = $20;
  D3D10_BIND_DEPTH_STENCIL = $40;

  D3D10_CPU_ACCESS_WRITE = $10000;
  D3D10_CPU_ACCESS_READ = $20000;

  D3D10_RESOURCE_MISC_GENERATE_MIPS = $1;
  D3D10_RESOURCE_MISC_SHARED = $2;
  D3D10_RESOURCE_MISC_TEXTURECUBE = $4;
  D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX = $10;
  D3D10_RESOURCE_MISC_GDI_COMPATIBLE = $20;

  D3D10_MAP_READ = 1;
  D3D10_MAP_WRITE = 2;
  D3D10_MAP_READ_WRITE = 3;
  D3D10_MAP_WRITE_DISCARD = 4;
  D3D10_MAP_WRITE_NO_OVERWRITE = 5;

  D3D10_MAP_FLAG_DO_NOT_WAIT = $100000;

  D3D10_RAISE_FLAG_DRIVER_INTERNAL_ERROR = $1;

  D3D10_CLEAR_DEPTH = $1;
  D3D10_CLEAR_STENCIL = $2;

  D3D10_COMPARISON_NEVER = 1;
  D3D10_COMPARISON_LESS = 2;
  D3D10_COMPARISON_EQUAL = 3;
  D3D10_COMPARISON_LESS_EQUAL = 4;
  D3D10_COMPARISON_GREATER = 5;
  D3D10_COMPARISON_NOT_EQUAL = 6;
  D3D10_COMPARISON_GREATER_EQUAL = 7;
  D3D10_COMPARISON_ALWAYS = 8;

  D3D10_DEPTH_WRITE_MASK_ZERO = 0;
  D3D10_DEPTH_WRITE_MASK_ALL = 1;

  D3D10_STENCIL_OP_KEEP = 1;
  D3D10_STENCIL_OP_ZERO = 2;
  D3D10_STENCIL_OP_REPLACE = 3;
  D3D10_STENCIL_OP_INCR_SAT = 4;
  D3D10_STENCIL_OP_DECR_SAT = 5;
  D3D10_STENCIL_OP_INVERT = 6;
  D3D10_STENCIL_OP_INCR = 7;
  D3D10_STENCIL_OP_DECR = 8;

  D3D10_BLEND_ZERO = 1;
  D3D10_BLEND_ONE = 2;
  D3D10_BLEND_SRC_COLOR = 3;
  D3D10_BLEND_INV_SRC_COLOR = 4;
  D3D10_BLEND_SRC_ALPHA = 5;
  D3D10_BLEND_INV_SRC_ALPHA = 6;
  D3D10_BLEND_DEST_ALPHA = 7;
  D3D10_BLEND_INV_DEST_ALPHA = 8;
  D3D10_BLEND_DEST_COLOR = 9;
  D3D10_BLEND_INV_DEST_COLOR = 10;
  D3D10_BLEND_SRC_ALPHA_SAT = 11;
  D3D10_BLEND_BLEND_FACTOR = 14;
  D3D10_BLEND_INV_BLEND_FACTOR = 15;
  D3D10_BLEND_SRC1_COLOR = 16;
  D3D10_BLEND_INV_SRC1_COLOR = 17;
  D3D10_BLEND_SRC1_ALPHA = 18;
  D3D10_BLEND_INV_SRC1_ALPHA = 19;

  D3D10_BLEND_OP_ADD = 1;
  D3D10_BLEND_OP_SUBTRACT = 2;
  D3D10_BLEND_OP_REV_SUBTRACT = 3;
  D3D10_BLEND_OP_MIN = 4;
  D3D10_BLEND_OP_MAX = 5;

  D3D10_COLOR_WRITE_ENABLE_RED = 1;
  D3D10_COLOR_WRITE_ENABLE_GREEN = 2;
  D3D10_COLOR_WRITE_ENABLE_BLUE = 4;
  D3D10_COLOR_WRITE_ENABLE_ALPHA = 8;
  D3D10_COLOR_WRITE_ENABLE_ALL = D3D10_COLOR_WRITE_ENABLE_RED or D3D10_COLOR_WRITE_ENABLE_GREEN or
    D3D10_COLOR_WRITE_ENABLE_BLUE or D3D10_COLOR_WRITE_ENABLE_ALPHA;

  D3D10_TEXTURECUBE_FACE_POSITIVE_X = 0;
  D3D10_TEXTURECUBE_FACE_NEGATIVE_X = 1;
  D3D10_TEXTURECUBE_FACE_POSITIVE_Y = 2;
  D3D10_TEXTURECUBE_FACE_NEGATIVE_Y = 3;
  D3D10_TEXTURECUBE_FACE_POSITIVE_Z = 4;
  D3D10_TEXTURECUBE_FACE_NEGATIVE_Z = 5;

  D3D10_FILTER_MIN_MAG_MIP_POINT = 0;
  D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR = $1;
  D3D10_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = $4;
  D3D10_FILTER_MIN_POINT_MAG_MIP_LINEAR = $5;
  D3D10_FILTER_MIN_LINEAR_MAG_MIP_POINT = $10;
  D3D10_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = $11;
  D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT = $14;
  D3D10_FILTER_MIN_MAG_MIP_LINEAR = $15;
  D3D10_FILTER_ANISOTROPIC = $55;
  D3D10_FILTER_COMPARISON_MIN_MAG_MIP_POINT = $80;
  D3D10_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = $81;
  D3D10_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = $84;
  D3D10_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = $85;
  D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = $90;
  D3D10_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = $91;
  D3D10_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = $94;
  D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = $95;
  D3D10_FILTER_COMPARISON_ANISOTROPIC = $D5;
  D3D10_FILTER_TEXT_1BIT = $80000000;

  D3D10_FILTER_TYPE_POINT = 0;
  D3D10_FILTER_TYPE_LINEAR = 1;

  D3D10_TEXTURE_ADDRESS_WRAP = 1;
  D3D10_TEXTURE_ADDRESS_MIRROR = 2;
  D3D10_TEXTURE_ADDRESS_CLAMP = 3;
  D3D10_TEXTURE_ADDRESS_BORDER = 4;
  D3D10_TEXTURE_ADDRESS_MIRROR_ONCE = 5;

  D3D10_FORMAT_SUPPORT_BUFFER = $1;
  D3D10_FORMAT_SUPPORT_IA_VERTEX_BUFFER = $2;
  D3D10_FORMAT_SUPPORT_IA_INDEX_BUFFER = $4;
  D3D10_FORMAT_SUPPORT_SO_BUFFER = $8;
  D3D10_FORMAT_SUPPORT_TEXTURE1D = $10;
  D3D10_FORMAT_SUPPORT_TEXTURE2D = $20;
  D3D10_FORMAT_SUPPORT_TEXTURE3D = $40;
  D3D10_FORMAT_SUPPORT_TEXTURECUBE = $80;
  D3D10_FORMAT_SUPPORT_SHADER_LOAD = $100;
  D3D10_FORMAT_SUPPORT_SHADER_SAMPLE = $200;
  D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON = $400;
  D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT = $800;
  D3D10_FORMAT_SUPPORT_MIP = $1000;
  D3D10_FORMAT_SUPPORT_MIP_AUTOGEN = $2000;
  D3D10_FORMAT_SUPPORT_RENDER_TARGET = $4000;
  D3D10_FORMAT_SUPPORT_BLENDABLE = $8000;
  D3D10_FORMAT_SUPPORT_DEPTH_STENCIL = $10000;
  D3D10_FORMAT_SUPPORT_CPU_LOCKABLE = $20000;
  D3D10_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE = $40000;
  D3D10_FORMAT_SUPPORT_DISPLAY = $80000;
  D3D10_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT = $100000;
  D3D10_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET = $200000;
  D3D10_FORMAT_SUPPORT_MULTISAMPLE_LOAD = $400000;
  D3D10_FORMAT_SUPPORT_SHADER_GATHER = $800000;
  D3D10_FORMAT_SUPPORT_BACK_BUFFER_CAST = $1000000;

  D3D10_ASYNC_GETDATA_DONOTFLUSH = $1;

  D3D10_QUERY_EVENT = 0;
  D3D10_QUERY_OCCLUSION = D3D10_QUERY_EVENT + 1;
  D3D10_QUERY_TIMESTAMP = D3D10_QUERY_OCCLUSION + 1;
  D3D10_QUERY_TIMESTAMP_DISJOINT = D3D10_QUERY_TIMESTAMP + 1;
  D3D10_QUERY_PIPELINE_STATISTICS = D3D10_QUERY_TIMESTAMP_DISJOINT + 1;
  D3D10_QUERY_OCCLUSION_PREDICATE = D3D10_QUERY_PIPELINE_STATISTICS + 1;
  D3D10_QUERY_SO_STATISTICS = D3D10_QUERY_OCCLUSION_PREDICATE + 1;
  D3D10_QUERY_SO_OVERFLOW_PREDICATE = D3D10_QUERY_SO_STATISTICS + 1;

  D3D10_QUERY_MISC_PREDICATEHINT = $1;

  D3D10_COUNTER_GPU_IDLE = 0;
  D3D10_COUNTER_VERTEX_PROCESSING = D3D10_COUNTER_GPU_IDLE + 1;
  D3D10_COUNTER_GEOMETRY_PROCESSING = D3D10_COUNTER_VERTEX_PROCESSING + 1;
  D3D10_COUNTER_PIXEL_PROCESSING = D3D10_COUNTER_GEOMETRY_PROCESSING + 1;
  D3D10_COUNTER_OTHER_GPU_PROCESSING = D3D10_COUNTER_PIXEL_PROCESSING + 1;
  D3D10_COUNTER_HOST_ADAPTER_BANDWIDTH_UTILIZATION = D3D10_COUNTER_OTHER_GPU_PROCESSING + 1;
  D3D10_COUNTER_LOCAL_VIDMEM_BANDWIDTH_UTILIZATION = D3D10_COUNTER_HOST_ADAPTER_BANDWIDTH_UTILIZATION + 1;
  D3D10_COUNTER_VERTEX_THROUGHPUT_UTILIZATION = D3D10_COUNTER_LOCAL_VIDMEM_BANDWIDTH_UTILIZATION + 1;
  D3D10_COUNTER_TRIANGLE_SETUP_THROUGHPUT_UTILIZATION = D3D10_COUNTER_VERTEX_THROUGHPUT_UTILIZATION + 1;
  D3D10_COUNTER_FILLRATE_THROUGHPUT_UTILIZATION = D3D10_COUNTER_TRIANGLE_SETUP_THROUGHPUT_UTILIZATION + 1;
  D3D10_COUNTER_VS_MEMORY_LIMITED = D3D10_COUNTER_FILLRATE_THROUGHPUT_UTILIZATION + 1;
  D3D10_COUNTER_VS_COMPUTATION_LIMITED = D3D10_COUNTER_VS_MEMORY_LIMITED + 1;
  D3D10_COUNTER_GS_MEMORY_LIMITED = D3D10_COUNTER_VS_COMPUTATION_LIMITED + 1;
  D3D10_COUNTER_GS_COMPUTATION_LIMITED = D3D10_COUNTER_GS_MEMORY_LIMITED + 1;
  D3D10_COUNTER_PS_MEMORY_LIMITED = D3D10_COUNTER_GS_COMPUTATION_LIMITED + 1;
  D3D10_COUNTER_PS_COMPUTATION_LIMITED = D3D10_COUNTER_PS_MEMORY_LIMITED + 1;
  D3D10_COUNTER_POST_TRANSFORM_CACHE_HIT_RATE = D3D10_COUNTER_PS_COMPUTATION_LIMITED + 1;
  D3D10_COUNTER_TEXTURE_CACHE_HIT_RATE = D3D10_COUNTER_POST_TRANSFORM_CACHE_HIT_RATE + 1;
  D3D10_COUNTER_DEVICE_DEPENDENT_0 = $40000000;

  D3D10_COUNTER_TYPE_FLOAT32 = 0;
  D3D10_COUNTER_TYPE_UINT16 = D3D10_COUNTER_TYPE_FLOAT32 + 1;
  D3D10_COUNTER_TYPE_UINT32 = D3D10_COUNTER_TYPE_UINT16 + 1;
  D3D10_COUNTER_TYPE_UINT64 = D3D10_COUNTER_TYPE_UINT32 + 1;

  D3D10_CREATE_DEVICE_SINGLETHREADED = $1;
  D3D10_CREATE_DEVICE_DEBUG = $2;
  D3D10_CREATE_DEVICE_SWITCH_TO_REF = $4;
  D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS = $8;
  D3D10_CREATE_DEVICE_ALLOW_NULL_FROM_MAP = $10;
  D3D10_CREATE_DEVICE_BGRA_SUPPORT = $20;
  D3D10_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY = $80;
  D3D10_CREATE_DEVICE_STRICT_VALIDATION = $200;
  D3D10_CREATE_DEVICE_DEBUGGABLE = $400;

  D3D10_FEATURE_LEVEL_10_0 = $A000;
  D3D10_FEATURE_LEVEL_10_1 = $A100;
  D3D10_FEATURE_LEVEL_9_1 = $9100;
  D3D10_FEATURE_LEVEL_9_2 = $9200;
  D3D10_FEATURE_LEVEL_9_3 = $9300;

  D3D10_STANDARD_MULTISAMPLE_PATTERN = $FFFFFFFF;
  D3D10_CENTER_MULTISAMPLE_PATTERN = $FFFFFFFE;

  D3D10_DRIVER_TYPE_HARDWARE = 0;
  D3D10_DRIVER_TYPE_REFERENCE = 1;
  D3D10_DRIVER_TYPE_NULL = 2;
  D3D10_DRIVER_TYPE_SOFTWARE = 3;
  D3D10_DRIVER_TYPE_WARP = 5;

  SID_ID3D10DeviceChild = '{9B7E4C00-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10DepthStencilState = '{2B4B1CC8-A4AD-41F8-8322-CA86FC3EC675}';
  SID_ID3D10BlendState = '{EDAD8D19-8A35-4D6D-8566-2EA276CDE161}';
  SID_ID3D10RasterizerState = '{A2A07292-89AF-4345-BE2E-C53D9FBB6E9F}';
  SID_ID3D10Resource = '{9B7E4C01-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Buffer = '{9B7E4C02-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Texture1D = '{9B7E4C03-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Texture2D = '{9B7E4C04-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Texture3D = '{9B7E4C05-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10View = '{C902B03F-60A7-49BA-9936-2A3AB37A7E33}';
  SID_ID3D10ShaderResourceView = '{9B7E4C07-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10RenderTargetView = '{9B7E4C08-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10DepthStencilView = '{9B7E4C09-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10VertexShader = '{9B7E4C0A-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10GeometryShader = '{6316BE88-54CD-4040-AB44-20461BC81F68}';
  SID_ID3D10PixelShader = '{4968B601-9D00-4CDE-8346-8E7F675819B6}';
  SID_ID3D10InputLayout = '{9B7E4C0B-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10SamplerState = '{9B7E4C0C-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Asynchronous = '{9B7E4C0D-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Query = '{9B7E4C0E-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Predicate = '{9B7E4C10-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Counter = '{9B7E4C11-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Device = '{9B7E4C0F-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Multithread = '{9B7E4E00-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10BlendState1 = '{EDAD8D99-8A35-4D6D-8566-2EA276CDE161}';
  SID_ID3D10ShaderResourceView1 = '{9B7E4C87-342C-4106-A19F-4F2704F689F0}';
  SID_ID3D10Device1 = '{9B7E4C8F-342C-4106-A19F-4F2704F689F0}';

  IID_ID3D10DeviceChild: TGuid = SID_ID3D10DeviceChild;
  IID_ID3D10DepthStencilState: TGuid = SID_ID3D10DepthStencilState;
  IID_ID3D10BlendState: TGuid = SID_ID3D10BlendState;
  IID_ID3D10RasterizerState: TGuid = SID_ID3D10RasterizerState;
  IID_ID3D10Resource: TGuid = SID_ID3D10Resource;
  IID_ID3D10Buffer: TGuid = SID_ID3D10Buffer;
  IID_ID3D10Texture1D: TGuid = SID_ID3D10Texture1D;
  IID_ID3D10Texture2D: TGuid = SID_ID3D10Texture2D;
  IID_ID3D10Texture3D: TGuid = SID_ID3D10Texture3D;
  IID_ID3D10View: TGuid = SID_ID3D10View;
  IID_ID3D10ShaderResourceView: TGuid = SID_ID3D10ShaderResourceView;
  IID_ID3D10RenderTargetView: TGuid = SID_ID3D10RenderTargetView;
  IID_ID3D10DepthStencilView: TGuid = SID_ID3D10DepthStencilView;
  IID_ID3D10VertexShader: TGuid = SID_ID3D10VertexShader;
  IID_ID3D10GeometryShader: TGuid = SID_ID3D10GeometryShader;
  IID_ID3D10PixelShader: TGuid = SID_ID3D10PixelShader;
  IID_ID3D10InputLayout: TGuid = SID_ID3D10InputLayout;
  IID_ID3D10SamplerState: TGuid = SID_ID3D10SamplerState;
  IID_ID3D10Asynchronous: TGuid = SID_ID3D10Asynchronous;
  IID_ID3D10Query: TGuid = SID_ID3D10Query;
  IID_ID3D10Predicate: TGuid = SID_ID3D10Predicate;
  IID_ID3D10Counter: TGuid = SID_ID3D10Counter;
  IID_ID3D10Device: TGuid = SID_ID3D10Device;
  IID_ID3D10Multithread: TGuid = SID_ID3D10Multithread;
  IID_ID3D10BlendState1: TGuid = SID_ID3D10BlendState1;
  IID_ID3D10ShaderResourceView1: TGuid = SID_ID3D10ShaderResourceView1;
  IID_ID3D10Device1: TGuid = SID_ID3D10Device1;

type
  PD3D10_PRIMITIVE_TOPOLOGY = ^D3D10_PRIMITIVE_TOPOLOGY;
  D3D10_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY;

  PD3D10_PRIMITIVE = ^D3D10_PRIMITIVE;
  D3D10_PRIMITIVE = D3D_PRIMITIVE;

  PD3D10_SRV_DIMENSION = ^D3D10_SRV_DIMENSION;
  D3D10_SRV_DIMENSION = D3D_SRV_DIMENSION;

  PD3D10_RECT = ^D3D10_RECT;
  D3D10_RECT = TRect;

  PD3D10_SRV_DIMENSION1 = ^D3D10_SRV_DIMENSION1;
  D3D10_SRV_DIMENSION1 = D3D_SRV_DIMENSION;

  PD3D10_INPUT_CLASSIFICATION = ^D3D10_INPUT_CLASSIFICATION;
  D3D10_INPUT_CLASSIFICATION = LongWord;

  PD3D10_FILL_MODE = ^D3D10_FILL_MODE;
  D3D10_FILL_MODE = LongWord;

  PD3D10_CULL_MODE = ^D3D10_CULL_MODE;
  D3D10_CULL_MODE = LongWord;

  PD3D10_RESOURCE_DIMENSION = ^D3D10_RESOURCE_DIMENSION;
  D3D10_RESOURCE_DIMENSION = LongWord;

  PD3D10_DSV_DIMENSION = ^D3D10_DSV_DIMENSION;
  D3D10_DSV_DIMENSION = LongWord;

  PD3D10_RTV_DIMENSION = ^D3D10_RTV_DIMENSION;
  D3D10_RTV_DIMENSION = LongWord;

  PD3D10_USAGE = ^D3D10_USAGE;
  D3D10_USAGE = LongWord;

  PD3D10_BIND_FLAG = ^D3D10_BIND_FLAG;
  D3D10_BIND_FLAG = LongWord;

  PD3D10_CPU_ACCESS_FLAG = ^D3D10_CPU_ACCESS_FLAG;
  D3D10_CPU_ACCESS_FLAG = LongWord;

  PD3D10_RESOURCE_MISC_FLAG = ^D3D10_RESOURCE_MISC_FLAG;
  D3D10_RESOURCE_MISC_FLAG = LongWord;

  PD3D10_MAP = ^D3D10_MAP;
  D3D10_MAP = LongWord;

  PD3D10_MAP_FLAG = ^D3D10_MAP_FLAG;
  D3D10_MAP_FLAG = LongWord;

  PD3D10_RAISE_FLAG = ^D3D10_RAISE_FLAG;
  D3D10_RAISE_FLAG = LongWord;

  PD3D10_CLEAR_FLAG = ^D3D10_CLEAR_FLAG;
  D3D10_CLEAR_FLAG = LongWord;

  PD3D10_COMPARISON_FUNC = ^D3D10_COMPARISON_FUNC;
  D3D10_COMPARISON_FUNC = LongWord;

  PD3D10_DEPTH_WRITE_MASK = ^D3D10_DEPTH_WRITE_MASK;
  D3D10_DEPTH_WRITE_MASK = LongWord;

  PD3D10_STENCIL_OP = ^D3D10_STENCIL_OP;
  D3D10_STENCIL_OP = LongWord;

  PD3D10_BLEND = ^D3D10_BLEND;
  D3D10_BLEND = LongWord;

  PD3D10_BLEND_OP = ^D3D10_BLEND_OP;
  D3D10_BLEND_OP = LongWord;

  PD3D10_COLOR_WRITE_ENABLE = ^D3D10_COLOR_WRITE_ENABLE;
  D3D10_COLOR_WRITE_ENABLE = LongWord;

  PD3D10_TEXTURECUBE_FACE = ^D3D10_TEXTURECUBE_FACE;
  D3D10_TEXTURECUBE_FACE = LongWord;

  PD3D10_FILTER = ^D3D10_FILTER;
  D3D10_FILTER = LongWord;

  PD3D10_FILTER_TYPE = ^D3D10_FILTER_TYPE;
  D3D10_FILTER_TYPE = LongWord;

  PD3D10_TEXTURE_ADDRESS_MODE = ^D3D10_TEXTURE_ADDRESS_MODE;
  D3D10_TEXTURE_ADDRESS_MODE = LongWord;

  PD3D10_FORMAT_SUPPORT = ^D3D10_FORMAT_SUPPORT;
  D3D10_FORMAT_SUPPORT = LongWord;

  PD3D10_ASYNC_GETDATA_FLAG = ^D3D10_ASYNC_GETDATA_FLAG;
  D3D10_ASYNC_GETDATA_FLAG = LongWord;

  PD3D10_QUERY = ^D3D10_QUERY;
  D3D10_QUERY = LongWord;

  PD3D10_QUERY_MISC_FLAG = ^D3D10_QUERY_MISC_FLAG;
  D3D10_QUERY_MISC_FLAG = LongWord;

  PD3D10_COUNTER = ^D3D10_COUNTER;
  D3D10_COUNTER = LongWord;

  PD3D10_COUNTER_TYPE = ^D3D10_COUNTER_TYPE;
  D3D10_COUNTER_TYPE = LongWord;

  PD3D10_CREATE_DEVICE_FLAG = ^D3D10_CREATE_DEVICE_FLAG;
  D3D10_CREATE_DEVICE_FLAG = LongWord;

  PD3D10_FEATURE_LEVEL1 = ^D3D10_FEATURE_LEVEL1;
  D3D10_FEATURE_LEVEL1 = LongWord;

  PD3D10_STANDARD_MULTISAMPLE_QUALITY_LEVELS = ^D3D10_STANDARD_MULTISAMPLE_QUALITY_LEVELS;
  D3D10_STANDARD_MULTISAMPLE_QUALITY_LEVELS = LongWord;

  PD3D10_DRIVER_TYPE = ^D3D10_DRIVER_TYPE;
  D3D10_DRIVER_TYPE = LongWord;

  PD3D10_INPUT_ELEMENT_DESC = ^D3D10_INPUT_ELEMENT_DESC;
  D3D10_INPUT_ELEMENT_DESC = record
    SemanticName: PAnsiChar;
    SemanticIndex: LongWord;
    Format: DXGI_FORMAT;
    InputSlot: LongWord;
    AlignedByteOffset: LongWord;
    InputSlotClass: D3D10_INPUT_CLASSIFICATION;
    InstanceDataStepRate: LongWord;
  end;

  PD3D10_SO_DECLARATION_ENTRY = ^D3D10_SO_DECLARATION_ENTRY;
  D3D10_SO_DECLARATION_ENTRY = record
    SemanticName: PAnsiChar;
    SemanticIndex: LongWord;
    StartComponent: Byte;
    ComponentCount: Byte;
    OutputSlot: Byte;
  end;

  PD3D10_VIEWPORT = ^D3D10_VIEWPORT;
  D3D10_VIEWPORT = record
    TopLeftX: LongInt;
    TopLeftY: LongInt;
    Width: LongWord;
    Height: LongWord;
    MinDepth: Single;
    MaxDepth: Single;
  end;

  PD3D10_BOX = ^D3D10_BOX;
  D3D10_BOX = record
    Left: LongWord;
    Top: LongWord;
    Front: LongWord;
    Right: LongWord;
    Bottom: LongWord;
    Back: LongWord;
  end;

  PD3D10_DEPTH_STENCILOP_DESC = ^D3D10_DEPTH_STENCILOP_DESC;
  D3D10_DEPTH_STENCILOP_DESC = record
    StencilFailOp: D3D10_STENCIL_OP;
    StencilDepthFailOp: D3D10_STENCIL_OP;
    StencilPassOp: D3D10_STENCIL_OP;
    StencilFunc: D3D10_COMPARISON_FUNC;
  end;

  PD3D10_DEPTH_STENCIL_DESC = ^D3D10_DEPTH_STENCIL_DESC;
  D3D10_DEPTH_STENCIL_DESC = record
    DepthEnable: LongBool;
    DepthWriteMask: D3D10_DEPTH_WRITE_MASK;
    DepthFunc: D3D10_COMPARISON_FUNC;
    StencilEnable: LongBool;
    StencilReadMask: Byte;
    StencilWriteMask: Byte;
    FrontFace: D3D10_DEPTH_STENCILOP_DESC;
    BackFace: D3D10_DEPTH_STENCILOP_DESC;
  end;

  PD3D10_BLEND_DESC = ^D3D10_BLEND_DESC;
  D3D10_BLEND_DESC = record
    AlphaToCoverageEnable: LongBool;
    BlendEnable: array[0..7] of LongBool;
    SrcBlend: D3D10_BLEND;
    DestBlend: D3D10_BLEND;
    BlendOp: D3D10_BLEND_OP;
    SrcBlendAlpha: D3D10_BLEND;
    DestBlendAlpha: D3D10_BLEND;
    BlendOpAlpha: D3D10_BLEND_OP;
    RenderTargetWriteMask: array[0..7] of Byte;
  end;

  PD3D10_RASTERIZER_DESC = ^D3D10_RASTERIZER_DESC;
  D3D10_RASTERIZER_DESC = record
    FillMode: D3D10_FILL_MODE;
    CullMode: D3D10_CULL_MODE;
    FrontCounterClockwise: LongBool;
    DepthBias: LongInt;
    DepthBiasClamp: Single;
    SlopeScaledDepthBias: Single;
    DepthClipEnable: LongBool;
    ScissorEnable: LongBool;
    MultisampleEnable: LongBool;
    AntialiasedLineEnable: LongBool;
  end;

  PD3D10_SUBRESOURCE_DATA = ^D3D10_SUBRESOURCE_DATA;
  D3D10_SUBRESOURCE_DATA = record
    SysMem: Pointer;
    SysMemPitch: LongWord;
    SysMemSlicePitch: LongWord;
  end;

  PD3D10_BUFFER_DESC = ^D3D10_BUFFER_DESC;
  D3D10_BUFFER_DESC = record
    ByteWidth: LongWord;
    Usage: D3D10_USAGE;
    BindFlags: LongWord;
    CPUAccessFlags: LongWord;
    MiscFlags: LongWord;
  end;

  PD3D10_TEXTURE1D_DESC = ^D3D10_TEXTURE1D_DESC;
  D3D10_TEXTURE1D_DESC = record
    Width: LongWord;
    MipLevels: LongWord;
    ArraySize: LongWord;
    Format: DXGI_FORMAT;
    Usage: D3D10_USAGE;
    BindFlags: LongWord;
    CPUAccessFlags: LongWord;
    MiscFlags: LongWord;
  end;

  PD3D10_TEXTURE2D_DESC = ^D3D10_TEXTURE2D_DESC;
  D3D10_TEXTURE2D_DESC = record
    Width: LongWord;
    Height: LongWord;
    MipLevels: LongWord;
    ArraySize: LongWord;
    Format: DXGI_FORMAT;
    SampleDesc: DXGI_SAMPLE_DESC;
    Usage: D3D10_USAGE;
    BindFlags: LongWord;
    CPUAccessFlags: LongWord;
    MiscFlags: LongWord;
  end;

  PD3D10_MAPPED_TEXTURE2D = ^D3D10_MAPPED_TEXTURE2D;
  D3D10_MAPPED_TEXTURE2D = record
    Data: Pointer;
    RowPitch: LongWord;
  end;

  PD3D10_TEXTURE3D_DESC = ^D3D10_TEXTURE3D_DESC;
  D3D10_TEXTURE3D_DESC = record
    Width: LongWord;
    Height: LongWord;
    Depth: LongWord;
    MipLevels: LongWord;
    Format: DXGI_FORMAT;
    Usage: D3D10_USAGE;
    BindFlags: LongWord;
    CPUAccessFlags: LongWord;
    MiscFlags: LongWord;
  end;

  PD3D10_MAPPED_TEXTURE3D = ^D3D10_MAPPED_TEXTURE3D;
  D3D10_MAPPED_TEXTURE3D = record
    Data: Pointer;
    RowPitch: LongWord;
    DepthPitch: LongWord;
  end;

  PD3D10_BUFFER_SRV = ^D3D10_BUFFER_SRV;
  D3D10_BUFFER_SRV = record
  case Integer of
    0: (FirstElement: LongWord;
        NumElements: LongWord);
    1: (ElementOffset: LongWord;
        ElementWidth: LongWord);
  end;

  PD3D10_TEX1D_SRV = ^D3D10_TEX1D_SRV;
  D3D10_TEX1D_SRV = record
    MostDetailedMip: LongWord;
    MipLevels: LongWord;
  end;

  PD3D10_TEX1D_ARRAY_SRV = ^D3D10_TEX1D_ARRAY_SRV;
  D3D10_TEX1D_ARRAY_SRV = record
    MostDetailedMip: LongWord;
    MipLevels: LongWord;
    FirstArraySlice: LongWord;
    ArraySize: LongWord;
  end;

  PD3D10_TEX2D_SRV = ^D3D10_TEX2D_SRV;
  D3D10_TEX2D_SRV = record
    MostDetailedMip: LongWord;
    MipLevels: LongWord;
  end;

  PD3D10_TEX2D_ARRAY_SRV = ^D3D10_TEX2D_ARRAY_SRV;
  D3D10_TEX2D_ARRAY_SRV = record
    MostDetailedMip: LongWord;
    MipLevels: LongWord;
    FirstArraySlice: LongWord;
    ArraySize: LongWord;
  end;

  PD3D10_TEX3D_SRV = ^D3D10_TEX3D_SRV;
  D3D10_TEX3D_SRV = record
    MostDetailedMip: LongWord;
    MipLevels: LongWord;
  end;

  PD3D10_TEXCUBE_SRV = ^D3D10_TEXCUBE_SRV;
  D3D10_TEXCUBE_SRV = record
    MostDetailedMip: LongWord;
    MipLevels: LongWord;
  end;

  PD3D10_TEX2DMS_SRV = ^D3D10_TEX2DMS_SRV;
  D3D10_TEX2DMS_SRV = record
    UnusedField_NothingToDefine: LongWord;
  end;

  PD3D10_TEX2DMS_ARRAY_SRV = ^D3D10_TEX2DMS_ARRAY_SRV;
  D3D10_TEX2DMS_ARRAY_SRV = record
    FirstArraySlice: LongWord;
    ArraySize: LongWord;
  end;

  PD3D10_SHADER_RESOURCE_VIEW_DESC = ^D3D10_SHADER_RESOURCE_VIEW_DESC;
  D3D10_SHADER_RESOURCE_VIEW_DESC = record
    Format: DXGI_FORMAT;
    ViewDimension: D3D10_SRV_DIMENSION;
    case Integer of
      0: (Buffer: D3D10_BUFFER_SRV);
      1: (Texture1D: D3D10_TEX1D_SRV);
      2: (Texture1DArray: D3D10_TEX1D_ARRAY_SRV);
      3: (Texture2D: D3D10_TEX2D_SRV);
      4: (Texture2DArray: D3D10_TEX2D_ARRAY_SRV);
      5: (Texture2DMS: D3D10_TEX2DMS_SRV);
      6: (Texture2DMSArray: D3D10_TEX2DMS_ARRAY_SRV);
      7: (Texture3D: D3D10_TEX3D_SRV);
      8: (TextureCube: D3D10_TEXCUBE_SRV);
  end;

  PD3D10_BUFFER_RTV = ^D3D10_BUFFER_RTV;
  D3D10_BUFFER_RTV = record
  case Integer of
    0: (FirstElement: LongWord;
        NumElements: LongWord);
    1: (ElementOffset: LongWord;
        ElementWidth: LongWord);
  end;

  PD3D10_TEX1D_RTV = ^D3D10_TEX1D_RTV;
  D3D10_TEX1D_RTV = record
    MipSlice: LongWord;
  end;

  PD3D10_TEX1D_ARRAY_RTV = ^D3D10_TEX1D_ARRAY_RTV;
  D3D10_TEX1D_ARRAY_RTV = record
    MipSlice: LongWord;
    FirstArraySlice: LongWord;
    ArraySize: LongWord;
  end;

  PD3D10_TEX2D_RTV = ^D3D10_TEX2D_RTV;
  D3D10_TEX2D_RTV = record
    MipSlice: LongWord;
  end;

  PD3D10_TEX2DMS_RTV = ^D3D10_TEX2DMS_RTV;
  D3D10_TEX2DMS_RTV = record
    UnusedField_NothingToDefine: LongWord;
  end;

  PD3D10_TEX2D_ARRAY_RTV = ^D3D10_TEX2D_ARRAY_RTV;
  D3D10_TEX2D_ARRAY_RTV = record
    MipSlice: LongWord;
    FirstArraySlice: LongWord;
    ArraySize: LongWord;
  end;

  PD3D10_TEX2DMS_ARRAY_RTV = ^D3D10_TEX2DMS_ARRAY_RTV;
  D3D10_TEX2DMS_ARRAY_RTV = record
    FirstArraySlice: LongWord;
    ArraySize: LongWord;
  end;

  PD3D10_TEX3D_RTV = ^D3D10_TEX3D_RTV;
  D3D10_TEX3D_RTV = record
    MipSlice: LongWord;
    FirstWSlice: LongWord;
    WSize: LongWord;
  end;

  PD3D10_RENDER_TARGET_VIEW_DESC = ^D3D10_RENDER_TARGET_VIEW_DESC;
  D3D10_RENDER_TARGET_VIEW_DESC = record
    Format: DXGI_FORMAT;
    ViewDimension: D3D10_RTV_DIMENSION;
    case Integer of
      0: (Buffer: D3D10_BUFFER_RTV);
      1: (Texture1D: D3D10_TEX1D_RTV);
      2: (Texture1DArray: D3D10_TEX1D_ARRAY_RTV);
      3: (Texture2D: D3D10_TEX2D_RTV);
      4: (Texture2DArray: D3D10_TEX2D_ARRAY_RTV);
      5: (Texture2DMS: D3D10_TEX2DMS_RTV);
      6: (Texture2DMSArray: D3D10_TEX2DMS_ARRAY_RTV);
      7: (Texture3D: D3D10_TEX3D_RTV);
  end;

  PD3D10_TEX1D_DSV = ^D3D10_TEX1D_DSV;
  D3D10_TEX1D_DSV = record
    MipSlice: LongWord;
  end;

  PD3D10_TEX1D_ARRAY_DSV = ^D3D10_TEX1D_ARRAY_DSV;
  D3D10_TEX1D_ARRAY_DSV = record
    MipSlice: LongWord;
    FirstArraySlice: LongWord;
    ArraySize: LongWord;
  end;

  PD3D10_TEX2D_DSV = ^D3D10_TEX2D_DSV;
  D3D10_TEX2D_DSV = record
    MipSlice: LongWord;
  end;

  PD3D10_TEX2D_ARRAY_DSV = ^D3D10_TEX2D_ARRAY_DSV;
  D3D10_TEX2D_ARRAY_DSV = record
    MipSlice: LongWord;
    FirstArraySlice: LongWord;
    ArraySize: LongWord;
  end;

  PD3D10_TEX2DMS_DSV = ^D3D10_TEX2DMS_DSV;
  D3D10_TEX2DMS_DSV = record
    UnusedField_NothingToDefine: LongWord;
  end;

  PD3D10_TEX2DMS_ARRAY_DSV = ^D3D10_TEX2DMS_ARRAY_DSV;
  D3D10_TEX2DMS_ARRAY_DSV = record
    FirstArraySlice: LongWord;
    ArraySize: LongWord;
  end;

  PD3D10_DEPTH_STENCIL_VIEW_DESC = ^D3D10_DEPTH_STENCIL_VIEW_DESC;
  D3D10_DEPTH_STENCIL_VIEW_DESC = record
    Format: DXGI_FORMAT;
    ViewDimension: D3D10_DSV_DIMENSION;
    case Integer of
      0: (Texture1D: D3D10_TEX1D_DSV);
      1: (Texture1DArray: D3D10_TEX1D_ARRAY_DSV);
      2: (Texture2D: D3D10_TEX2D_DSV);
      3: (Texture2DArray: D3D10_TEX2D_ARRAY_DSV);
      4: (Texture2DMS: D3D10_TEX2DMS_DSV);
      5: (Texture2DMSArray: D3D10_TEX2DMS_ARRAY_DSV);
  end;

  PD3D10_SAMPLER_DESC = ^D3D10_SAMPLER_DESC;
  D3D10_SAMPLER_DESC = record
    Filter: D3D10_FILTER;
    AddressU: D3D10_TEXTURE_ADDRESS_MODE;
    AddressV: D3D10_TEXTURE_ADDRESS_MODE;
    AddressW: D3D10_TEXTURE_ADDRESS_MODE;
    MipLODBias: Single;
    MaxAnisotropy: LongWord;
    ComparisonFunc: D3D10_COMPARISON_FUNC;
    BorderColor: array[0..3] of Single;
    MinLOD: Single;
    MaxLOD: Single;
  end;

  PD3D10_QUERY_DESC = ^D3D10_QUERY_DESC;
  D3D10_QUERY_DESC = record
    Query: D3D10_QUERY;
    MiscFlags: LongWord;
  end;

  PD3D10_QUERY_DATA_TIMESTAMP_DISJOINT = ^D3D10_QUERY_DATA_TIMESTAMP_DISJOINT;
  D3D10_QUERY_DATA_TIMESTAMP_DISJOINT = record
    Frequency: UInt64;
    Disjoint: LongBool;
  end;

  PD3D10_QUERY_DATA_PIPELINE_STATISTICS = ^D3D10_QUERY_DATA_PIPELINE_STATISTICS;
  D3D10_QUERY_DATA_PIPELINE_STATISTICS = record
    IAVertices: UInt64;
    IAPrimitives: UInt64;
    VSInvocations: UInt64;
    GSInvocations: UInt64;
    GSPrimitives: UInt64;
    CInvocations: UInt64;
    CPrimitives: UInt64;
    PSInvocations: UInt64;
  end;

  PD3D10_QUERY_DATA_SO_STATISTICS = ^D3D10_QUERY_DATA_SO_STATISTICS;
  D3D10_QUERY_DATA_SO_STATISTICS = record
    NumPrimitivesWritten: UInt64;
    PrimitivesStorageNeeded: UInt64;
  end;

  PD3D10_COUNTER_DESC = ^D3D10_COUNTER_DESC;
  D3D10_COUNTER_DESC = record
    Counter: D3D10_COUNTER;
    MiscFlags: LongWord;
  end;

  PD3D10_COUNTER_INFO = ^D3D10_COUNTER_INFO;
  D3D10_COUNTER_INFO = record
    LastDeviceDependentCounter: D3D10_COUNTER;
    NumSimultaneousCounters: LongWord;
    NumDetectableParallelUnits: Byte;
  end;

  PD3D10_RENDER_TARGET_BLEND_DESC1 = ^D3D10_RENDER_TARGET_BLEND_DESC1;
  D3D10_RENDER_TARGET_BLEND_DESC1 = record
    BlendEnable: LongBool;
    SrcBlend: D3D10_BLEND;
    DestBlend: D3D10_BLEND;
    BlendOp: D3D10_BLEND_OP;
    SrcBlendAlpha: D3D10_BLEND;
    DestBlendAlpha: D3D10_BLEND;
    BlendOpAlpha: D3D10_BLEND_OP;
    RenderTargetWriteMask: Byte;
  end;

  PD3D10_BLEND_DESC1 = ^D3D10_BLEND_DESC1;
  D3D10_BLEND_DESC1 = record
    AlphaToCoverageEnable: LongBool;
    IndependentBlendEnable: LongBool;
    RenderTarget: array[0..7] of D3D10_RENDER_TARGET_BLEND_DESC1;
  end;

  PD3D10_TEXCUBE_ARRAY_SRV1 = ^D3D10_TEXCUBE_ARRAY_SRV1;
  D3D10_TEXCUBE_ARRAY_SRV1 = record
    MostDetailedMip: LongWord;
    MipLevels: LongWord;
    First2DArrayFace: LongWord;
    NumCubes: LongWord;
  end;

  PD3D10_SHADER_RESOURCE_VIEW_DESC1 = ^D3D10_SHADER_RESOURCE_VIEW_DESC1;
  D3D10_SHADER_RESOURCE_VIEW_DESC1 = record
    Format: DXGI_FORMAT;
    ViewDimension: D3D10_SRV_DIMENSION1;
    case Integer of
      0: (Buffer: D3D10_BUFFER_SRV);
      1: (Texture1D: D3D10_TEX1D_SRV);
      2: (Texture1DArray: D3D10_TEX1D_ARRAY_SRV);
      3: (Texture2D: D3D10_TEX2D_SRV);
      4: (Texture2DArray: D3D10_TEX2D_ARRAY_SRV);
      5: (Texture2DMS: D3D10_TEX2DMS_SRV);
      6: (Texture2DMSArray: D3D10_TEX2DMS_ARRAY_SRV);
      7: (Texture3D: D3D10_TEX3D_SRV);
      8: (TextureCube: D3D10_TEXCUBE_SRV);
      9: (TextureCubeArray: D3D10_TEXCUBE_ARRAY_SRV1);
  end;

  ID3D10Device = interface;

  PID3D10DeviceChild = ^ID3D10DeviceChild;
  ID3D10DeviceChild = interface(IUnknown)
    [SID_ID3D10DeviceChild]
    procedure GetDevice(out Device: ID3D10Device); stdcall;
    function GetPrivateData(const Guid: TGuid; var DataSize: LongWord; Data: Pointer): HResult; stdcall;
    function SetPrivateData(const Guid: TGuid; DataSize: LongWord; Data: Pointer): HResult; stdcall;
    function SetPrivateDataInterface(const Guid: TGuid; Data: IUnknown): HResult; stdcall;
  end;

  PID3D10DepthStencilState = ^ID3D10DepthStencilState;
  ID3D10DepthStencilState = interface(ID3D10DeviceChild)
    [SID_ID3D10DepthStencilState]
    procedure GetDesc(out Desc: D3D10_DEPTH_STENCIL_DESC); stdcall;
  end;

  PID3D10BlendState = ^ID3D10BlendState;
  ID3D10BlendState = interface(ID3D10DeviceChild)
    [SID_ID3D10BlendState]
    procedure GetDesc(out Desc: D3D10_BLEND_DESC); stdcall;
  end;

  PID3D10RasterizerState = ^ID3D10RasterizerState;
  ID3D10RasterizerState = interface(ID3D10DeviceChild)
    [SID_ID3D10RasterizerState]
    procedure GetDesc(out Desc: D3D10_RASTERIZER_DESC); stdcall;
  end;

  PID3D10Resource = ^ID3D10Resource;
  ID3D10Resource = interface(ID3D10DeviceChild)
    [SID_ID3D10Resource]
    procedure GetType(out RType: D3D10_RESOURCE_DIMENSION); stdcall;
    procedure SetEvictionPriority(EvictionPriority: LongWord); stdcall;
    function GetEvictionPriority: LongWord; stdcall;
  end;

  PID3D10Buffer = ^ID3D10Buffer;
  ID3D10Buffer = interface(ID3D10Resource)
    [SID_ID3D10Buffer]
    function Map(MapType: D3D10_MAP; MapFlags: LongWord; out Data): HResult; stdcall;
    procedure Unmap; stdcall;
    procedure GetDesc(out Desc: D3D10_BUFFER_DESC); stdcall;
  end;

  PID3D10Texture1D = ^ID3D10Texture1D;
  ID3D10Texture1D = interface(ID3D10Resource)
    [SID_ID3D10Texture1D]
    function Map(Subresource: LongWord; MapType: D3D10_MAP; MapFlags: LongWord; out Data): HResult; stdcall;
    procedure Unmap(Subresource: LongWord); stdcall;
    procedure GetDesc(out Desc: D3D10_TEXTURE1D_DESC); stdcall;
  end;

  PID3D10Texture2D = ^ID3D10Texture2D;
  ID3D10Texture2D = interface(ID3D10Resource)
    [SID_ID3D10Texture2D]
    function Map(Subresource: LongWord; MapType: D3D10_MAP; MapFlags: LongWord; 
      out MappedTex2D: D3D10_MAPPED_TEXTURE2D): HResult; stdcall;
    procedure Unmap(Subresource: LongWord); stdcall;
    procedure GetDesc(out Desc: D3D10_TEXTURE2D_DESC); stdcall;
  end;

  PID3D10Texture3D = ^ID3D10Texture3D;
  ID3D10Texture3D = interface(ID3D10Resource)
    [SID_ID3D10Texture3D]
    function Map(Subresource: LongWord; MapType: D3D10_MAP; MapFlags: LongWord; 
      out MappedTex3D: D3D10_MAPPED_TEXTURE3D): HResult; stdcall;
    procedure Unmap(Subresource: LongWord); stdcall;
    procedure GetDesc(out Desc: D3D10_TEXTURE3D_DESC); stdcall;
  end;

  PID3D10View = ^ID3D10View;
  ID3D10View = interface(ID3D10DeviceChild)
    [SID_ID3D10View]
    procedure GetResource(out Resource: ID3D10Resource); stdcall;
  end;

  PID3D10ShaderResourceView = ^ID3D10ShaderResourceView;
  ID3D10ShaderResourceView = interface(ID3D10View)
    [SID_ID3D10ShaderResourceView]
    procedure GetDesc(out Desc: D3D10_SHADER_RESOURCE_VIEW_DESC); stdcall;
  end;

  PID3D10RenderTargetView = ^ID3D10RenderTargetView;
  ID3D10RenderTargetView = interface(ID3D10View)
    [SID_ID3D10RenderTargetView]
    procedure GetDesc(out Desc: D3D10_RENDER_TARGET_VIEW_DESC); stdcall;
  end;

  PID3D10DepthStencilView = ^ID3D10DepthStencilView;
  ID3D10DepthStencilView = interface(ID3D10View)
    [SID_ID3D10DepthStencilView]
    procedure GetDesc(out Desc: D3D10_DEPTH_STENCIL_VIEW_DESC); stdcall;
  end;

  PID3D10VertexShader = ^ID3D10VertexShader;
  ID3D10VertexShader = interface(ID3D10DeviceChild)
    [SID_ID3D10VertexShader]
  end;

  PID3D10GeometryShader = ^ID3D10GeometryShader;
  ID3D10GeometryShader = interface(ID3D10DeviceChild)
    [SID_ID3D10GeometryShader]
  end;

  PID3D10PixelShader = ^ID3D10PixelShader;
  ID3D10PixelShader = interface(ID3D10DeviceChild)
    [SID_ID3D10PixelShader]
  end;

  PID3D10InputLayout = ^ID3D10InputLayout;
  ID3D10InputLayout = interface(ID3D10DeviceChild)
    [SID_ID3D10InputLayout]
  end;

  PID3D10SamplerState = ^ID3D10SamplerState;
  ID3D10SamplerState = interface(ID3D10DeviceChild)
    [SID_ID3D10SamplerState]
    procedure GetDesc(out Desc: D3D10_SAMPLER_DESC); stdcall;
  end;

  PID3D10Asynchronous = ^ID3D10Asynchronous;
  ID3D10Asynchronous = interface(ID3D10DeviceChild)
    [SID_ID3D10Asynchronous]
    procedure &Begin; stdcall;
    procedure &End; stdcall;
    function GetData(Data: Pointer; DataSize, GetDataFlags: LongWord): HResult; stdcall;
    function GetDataSize: LongWord; stdcall;
  end;

  PID3D10Query = ^ID3D10Query;
  ID3D10Query = interface(ID3D10Asynchronous)
    [SID_ID3D10Query]
    procedure GetDesc(out Desc: D3D10_QUERY_DESC); stdcall;
  end;

  PID3D10Predicate = ^ID3D10Predicate;
  ID3D10Predicate = interface(ID3D10Query)
    [SID_ID3D10Predicate]
  end;

  PID3D10Counter = ^ID3D10Counter;
  ID3D10Counter = interface(ID3D10Asynchronous)
    [SID_ID3D10Counter]
    procedure GetDesc(out Desc: D3D10_COUNTER_DESC); stdcall;
  end;

  PID3D10Device = ^ID3D10Device;
  ID3D10Device = interface(IUnknown)
    [SID_ID3D10Device]
    procedure VSSetConstantBuffers(StartSlot, NumBuffers: LongWord; ConstantBuffers: PID3D10Buffer); stdcall;
    procedure PSSetShaderResources(StartSlot, NumViews: LongWord; 
      ShaderResourceViews: PID3D10ShaderResourceView); stdcall;
    procedure PSSetShader(PixelShader: ID3D10PixelShader); stdcall;
    procedure PSSetSamplers(StartSlot, NumSamplers: LongWord; Samplers: PID3D10SamplerState); stdcall;
    procedure VSSetShader(VertexShader: ID3D10VertexShader); stdcall;
    procedure DrawIndexed(IndexCount, StartIndexLocation: LongWord; BaseVertexLocation: LongInt); stdcall;
    procedure Draw(VertexCount, StartVertexLocation: LongWord); stdcall;
    procedure PSSetConstantBuffers(StartSlot, NumBuffers: LongWord; ConstantBuffers: PID3D10Buffer); stdcall;
    procedure IASetInputLayout(InputLayout: ID3D10InputLayout); stdcall;
    procedure IASetVertexBuffers(StartSlot, NumBuffers: LongWord; VertexBuffers: PID3D10Buffer; Strides, 
      Offsets: PLongWord); stdcall;
    procedure IASetIndexBuffer(IndexBuffer: ID3D10Buffer; Format: DXGI_FORMAT; Offset: LongWord); stdcall;
    procedure DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation: LongWord; 
      BaseVertexLocation: LongInt; StartInstanceLocation: LongWord); stdcall;
    procedure DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation, 
      StartInstanceLocation: LongWord); stdcall;
    procedure GSSetConstantBuffers(StartSlot, NumBuffers: LongWord; ConstantBuffers: PID3D10Buffer); stdcall;
    procedure GSSetShader(Shader: ID3D10GeometryShader); stdcall;
    procedure IASetPrimitiveTopology(Topology: D3D10_PRIMITIVE_TOPOLOGY); stdcall;
    procedure VSSetShaderResources(StartSlot, NumViews: LongWord; 
      ShaderResourceViews: PID3D10ShaderResourceView); stdcall;
    procedure VSSetSamplers(StartSlot, NumSamplers: LongWord; Samplers: PID3D10SamplerState); stdcall;
    procedure SetPredication(Predicate: ID3D10Predicate; PredicateValue: LongBool); stdcall;
    procedure GSSetShaderResources(StartSlot, NumViews: LongWord; 
      ShaderResourceViews: PID3D10ShaderResourceView); stdcall;
    procedure GSSetSamplers(StartSlot, NumSamplers: LongWord; Samplers: PID3D10SamplerState); stdcall;
    procedure OMSetRenderTargets(NumViews: LongWord; RenderTargetViews: PID3D10RenderTargetView; 
      DepthStencilView: ID3D10DepthStencilView); stdcall;
    procedure OMSetBlendState(BlendState: ID3D10BlendState; BlendFactor: PFourSingleArray;
      SampleMask: LongWord); stdcall;
    procedure OMSetDepthStencilState(DepthStencilState: ID3D10DepthStencilState; StencilRef: LongWord); stdcall;
    procedure SOSetTargets(NumBuffers: LongWord; SOTargets: PID3D10Buffer; Offsets: PLongWord); stdcall;
    procedure DrawAuto; stdcall;
    procedure RSSetState(RasterizerState: ID3D10RasterizerState); stdcall;
    procedure RSSetViewports(NumViewports: LongWord; Viewports: PD3D10_VIEWPORT); stdcall;
    procedure RSSetScissorRects(NumRects: LongWord; Rects: PD3D10_RECT); stdcall;
    procedure CopySubresourceRegion(DstResource: ID3D10Resource; DstSubresource, DstX, DstY, DstZ: LongWord; 
      SrcResource: ID3D10Resource; SrcSubresource: LongWord; SrcBox: PD3D10_BOX); stdcall;
    procedure CopyResource(DstResource, SrcResource: ID3D10Resource); stdcall;
    procedure UpdateSubresource(DstResource: ID3D10Resource; DstSubresource: LongWord; DstBox: PD3D10_BOX; 
      const SrcData: Pointer; SrcRowPitch, SrcDepthPitch: LongWord); stdcall;
    procedure ClearRenderTargetView(RenderTargetView: ID3D10RenderTargetView; 
      const ColorRGBA: TFourSingleArray); stdcall;
    procedure ClearDepthStencilView(DepthStencilView: ID3D10DepthStencilView; ClearFlags: LongWord; Depth: Single; 
      Stencil: Byte); stdcall;
    procedure GenerateMips(ShaderResourceView: ID3D10ShaderResourceView); stdcall;
    procedure ResolveSubresource(DstResource: ID3D10Resource; DstSubresource: LongWord; SrcResource: ID3D10Resource; 
      SrcSubresource: LongWord; Format: DXGI_FORMAT); stdcall;
    procedure VSGetConstantBuffers(StartSlot, NumBuffers: LongWord; ConstantBuffers: PID3D10Buffer); stdcall;
    procedure PSGetShaderResources(StartSlot, NumViews: LongWord; 
      ShaderResourceViews: PID3D10ShaderResourceView); stdcall;
    procedure PSGetShader(out PixelShader: ID3D10PixelShader); stdcall;
    procedure PSGetSamplers(StartSlot, NumSamplers: LongWord; Samplers: PID3D10SamplerState); stdcall;
    procedure VSGetShader(out VertexShader: ID3D10VertexShader); stdcall;
    procedure PSGetConstantBuffers(StartSlot, NumBuffers: LongWord; ConstantBuffers: PID3D10Buffer); stdcall;
    procedure IAGetInputLayout(out InputLayout: ID3D10InputLayout); stdcall;
    procedure IAGetVertexBuffers(StartSlot, NumBuffers: LongWord; VertexBuffers: PID3D10Buffer; Strides, 
      Offsets: PLongWord); stdcall;
    procedure IAGetIndexBuffer(IndexBuffer: PID3D10Buffer; Format: PDXGI_FORMAT; Offset: PLongWord); stdcall;
    procedure GSGetConstantBuffers(StartSlot, NumBuffers: LongWord; ConstantBuffers: PID3D10Buffer); stdcall;
    procedure GSGetShader(out GeometryShader: ID3D10GeometryShader); stdcall;
    procedure IAGetPrimitiveTopology(out Topology: D3D10_PRIMITIVE_TOPOLOGY); stdcall;
    procedure VSGetShaderResources(StartSlot, NumViews: LongWord; 
      ShaderResourceViews: PID3D10ShaderResourceView); stdcall;
    procedure VSGetSamplers(StartSlot, NumSamplers: LongWord; Samplers: PID3D10SamplerState); stdcall;
    procedure GetPredication(Predicate: PID3D10Predicate; PredicateValue: PLongBool); stdcall;
    procedure GSGetShaderResources(StartSlot, NumViews: LongWord; 
      ShaderResourceViews: PID3D10ShaderResourceView); stdcall;
    procedure GSGetSamplers(StartSlot, NumSamplers: LongWord; Samplers: PID3D10SamplerState); stdcall;
    procedure OMGetRenderTargets(NumViews: LongWord; RenderTargetViews: PID3D10RenderTargetView; 
      DepthStencilView: PID3D10DepthStencilView); stdcall;
    procedure OMGetBlendState(BlendState: PID3D10BlendState; BlendFactor: PFourSingleArray;
      SampleMask: PLongWord); stdcall;
    procedure OMGetDepthStencilState(DepthStencilState: PID3D10DepthStencilState; StencilRef: PLongWord); stdcall;
    procedure SOGetTargets(NumBuffers: LongWord; SOTargets: PID3D10Buffer; Offsets: PLongWord); stdcall;
    procedure RSGetState(out RasterizerState: ID3D10RasterizerState); stdcall;
    procedure RSGetViewports(var NumViewports: LongWord; Viewports: PD3D10_VIEWPORT); stdcall;
    procedure RSGetScissorRects(var NumRects: LongWord; Rects: PD3D10_RECT); stdcall;
    function GetDeviceRemovedReason: HResult; stdcall;
    function SetExceptionMode(RaiseFlags: LongWord): HResult; stdcall;
    function GetExceptionMode: LongWord; stdcall;
    function GetPrivateData(const Guid: TGuid; var DataSize: LongWord; Data: Pointer): HResult; stdcall;
    function SetPrivateData(const Guid: TGuid; DataSize: LongWord; Data: Pointer): HResult; stdcall;
    function SetPrivateDataInterface(const Guid: TGuid; Data: IUnknown): HResult; stdcall;
    procedure ClearState; stdcall;
    procedure Flush; stdcall;
    function CreateBuffer(const Desc: D3D10_BUFFER_DESC; InitialData: PD3D10_SUBRESOURCE_DATA;
      Buffer: PID3D10Buffer): HResult; stdcall;
    function CreateTexture1D(const Desc: D3D10_TEXTURE1D_DESC; InitialData: PD3D10_SUBRESOURCE_DATA; 
      out Texture1D: ID3D10Texture1D): HResult; stdcall;
    function CreateTexture2D(const Desc: D3D10_TEXTURE2D_DESC; InitialData: PD3D10_SUBRESOURCE_DATA; 
      out Texture2D: ID3D10Texture2D): HResult; stdcall;
    function CreateTexture3D(const Desc: D3D10_TEXTURE3D_DESC; InitialData: PD3D10_SUBRESOURCE_DATA; 
      out Texture3D: ID3D10Texture3D): HResult; stdcall;
    function CreateShaderResourceView(Resource: ID3D10Resource; Desc: PD3D10_SHADER_RESOURCE_VIEW_DESC; 
      SRView: PID3D10ShaderResourceView): HResult; stdcall;
    function CreateRenderTargetView(Resource: ID3D10Resource; Desc: PD3D10_RENDER_TARGET_VIEW_DESC; 
      RTView: PID3D10RenderTargetView): HResult; stdcall;
    function CreateDepthStencilView(Resource: ID3D10Resource; Desc: PD3D10_DEPTH_STENCIL_VIEW_DESC; 
      DepthStencilView: PID3D10DepthStencilView): HResult; stdcall;
    function CreateInputLayout(InputElementDescs: PD3D10_INPUT_ELEMENT_DESC; NumElements: LongWord; 
      ShaderBytecodeWithInputSignature: Pointer; BytecodeLength: SIZE_T;
      InputLayout: PID3D10InputLayout): HResult; stdcall;
    function CreateVertexShader(ShaderBytecode: Pointer; BytecodeLength: SIZE_T; 
      VertexShader: PID3D10VertexShader): HResult; stdcall;
    function CreateGeometryShader(ShaderBytecode: Pointer; BytecodeLength: SIZE_T; 
      GeometryShader: PID3D10GeometryShader): HResult; stdcall;
    function CreateGeometryShaderWithStreamOutput(ShaderBytecode: Pointer; BytecodeLength: SIZE_T; 
      SODeclaration: PD3D10_SO_DECLARATION_ENTRY; NumEntries, OutputStreamStride: LongWord; 
      GeometryShader: PID3D10GeometryShader): HResult; stdcall;
    function CreatePixelShader(ShaderBytecode: Pointer; BytecodeLength: SIZE_T; 
      PixelShader: PID3D10PixelShader): HResult; stdcall;
    function CreateBlendState(const BlendStateDesc: D3D10_BLEND_DESC;
      BlendState: PID3D10BlendState): HResult; stdcall;
    function CreateDepthStencilState(const DepthStencilDesc: D3D10_DEPTH_STENCIL_DESC; 
      DepthStencilState: PID3D10DepthStencilState): HResult; stdcall;
    function CreateRasterizerState(const RasterizerDesc: D3D10_RASTERIZER_DESC; 
      RasterizerState: PID3D10RasterizerState): HResult; stdcall;
    function CreateSamplerState(const SamplerDesc: D3D10_SAMPLER_DESC; 
      SamplerState: PID3D10SamplerState): HResult; stdcall;
    function CreateQuery(const QueryDesc: D3D10_QUERY_DESC; Query: PID3D10Query): HResult; stdcall;
    function CreatePredicate(const PredicateDesc: D3D10_QUERY_DESC; Predicate: PID3D10Predicate): HResult; stdcall;
    function CreateCounter(const CounterDesc: D3D10_COUNTER_DESC; Counter: PID3D10Counter): HResult; stdcall;
    function CheckFormatSupport(Format: DXGI_FORMAT; out FormatSupport: LongWord): HResult; stdcall;
    function CheckMultisampleQualityLevels(Format: DXGI_FORMAT; SampleCount: LongWord; 
      out NumQualityLevels: LongWord): HResult; stdcall;
    procedure CheckCounterInfo(out CounterInfo: D3D10_COUNTER_INFO); stdcall;
    function CheckCounter(const Desc: D3D10_COUNTER_DESC; out _Type: D3D10_COUNTER_TYPE; out ActiveCounters: LongWord; 
      Name: PAnsiChar; NameLength: PLongWord; Units: PAnsiChar; UnitsLength: PLongWord; Description: PAnsiChar;
      DescriptionLength: PLongWord): HResult; stdcall;
    function GetCreationFlags: LongWord; stdcall;
    function OpenSharedResource(HResource: THandle; const ReturnedInterface: TGuid;
      Resource: Pointer): HResult; stdcall;
    procedure SetTextFilterSize(Width, Height: LongWord); stdcall;
    procedure GetTextFilterSize(Width, Height: PLongWord); stdcall;
  end;

  PID3D10Multithread = ^ID3D10Multithread;
  ID3D10Multithread = interface(IUnknown)
    [SID_ID3D10Multithread]
    procedure Enter; stdcall;
    procedure Leave; stdcall;
    function SetMultithreadProtected(BMTProtect: LongBool): LongBool; stdcall;
    function GetMultithreadProtected: LongBool; stdcall;
  end;

  PID3D10BlendState1 = ^ID3D10BlendState1;
  ID3D10BlendState1 = interface(ID3D10BlendState)
    [SID_ID3D10BlendState1]
    procedure GetDesc1(out Desc: D3D10_BLEND_DESC1); stdcall;
  end;

  PID3D10ShaderResourceView1 = ^ID3D10ShaderResourceView1;
  ID3D10ShaderResourceView1 = interface(ID3D10ShaderResourceView)
    [SID_ID3D10ShaderResourceView1]
    procedure GetDesc1(out Desc: D3D10_SHADER_RESOURCE_VIEW_DESC1); stdcall;
  end;

  PID3D10Device1 = ^ID3D10Device1;
  ID3D10Device1 = interface(ID3D10Device)
    [SID_ID3D10Device1]
    function CreateShaderResourceView1(Resource: ID3D10Resource; Desc: PD3D10_SHADER_RESOURCE_VIEW_DESC1;
      SRView: PID3D10ShaderResourceView1): HResult; stdcall;
    function CreateBlendState1(const BlendStateDesc: D3D10_BLEND_DESC1; 
      BlendState: PID3D10BlendState1): HResult; stdcall;
    function GetFeatureLevel: D3D10_FEATURE_LEVEL1; stdcall;
  end;

  TD3D10CreateDevice = function(Adapter: IDXGIAdapter; DriverType: D3D10_DRIVER_TYPE; Software: HMODULE; Flags,
    SDKVersion: LongWord; Device: PID3D10Device): HResult; stdcall;

  TD3D10CreateDeviceAndSwapChain = function(Adapter: IDXGIAdapter; DriverType: D3D10_DRIVER_TYPE; Software: HMODULE;
    Flags, SDKVersion: LongWord; SwapChainDesc: PDXGI_SWAP_CHAIN_DESC; SwapChain: PIDXGISwapChain;
    Device: PID3D10Device): HResult; stdcall;

  TD3D10CreateDevice1 = function(Adapter: IDXGIAdapter; DriverType: D3D10_DRIVER_TYPE; Software: HMODULE;
    Flags: LongWord; HardwareLevel: D3D10_FEATURE_LEVEL1; SDKVersion: LongWord;
    Device: PID3D10Device1): HResult; stdcall;

  TD3D10CreateDeviceAndSwapChain1 = function(Adapter: IDXGIAdapter; DriverType: D3D10_DRIVER_TYPE; Software: HMODULE;
    Flags: LongWord; HardwareLevel: D3D10_FEATURE_LEVEL1; SDKVersion: LongWord; SwapChainDesc: PDXGI_SWAP_CHAIN_DESC;
    SwapChain: PIDXGISwapChain; Device: PID3D10Device1): HResult; stdcall;

  TD3D10CreateBlob = function(NumBytes: SIZE_T; out Buffer: ID3D10Blob): HResult; stdcall;

var
  D3D10CreateDevice: TD3D10CreateDevice = nil;
  D3D10CreateDeviceAndSwapChain: TD3D10CreateDeviceAndSwapChain = nil;

  D3D10CreateDevice1: TD3D10CreateDevice1 = nil;
  D3D10CreateDeviceAndSwapChain1: TD3D10CreateDeviceAndSwapChain1 = nil;

  D3D10CreateBlob: TD3D10CreateBlob = nil;

function LinkD3D10: Boolean;
procedure UnlinkD3D10;

implementation

const
  LibraryD3D10 = 'd3d10.dll';

var
  LibraryHandle: HModule = 0;

procedure ResetReferences;
begin
  D3D10CreateDevice := nil;
  D3D10CreateDeviceAndSwapChain := nil;
  D3D10CreateDevice1 := nil;
  D3D10CreateDeviceAndSwapChain1 := nil;
  D3D10CreateBlob := nil;
end;

function LinkD3D10: Boolean;
begin
  if LibraryHandle = 0 then
  begin
    LibraryHandle := LoadLibrary(LibraryD3D10);
    if LibraryHandle = 0 then
      Exit(False);

    D3D10CreateDevice := GetProcAddress(LibraryHandle, 'D3D10CreateDevice');
    D3D10CreateDeviceAndSwapChain := GetProcAddress(LibraryHandle, 'D3D10CreateDeviceAndSwapChain');

    D3D10CreateDevice1 := GetProcAddress(LibraryHandle, 'D3D10CreateDevice1');
    D3D10CreateDeviceAndSwapChain1 := GetProcAddress(LibraryHandle, 'D3D10CreateDeviceAndSwapChain1');

    D3D10CreateBlob := GetProcAddress(LibraryHandle, 'D3D10CreateBlob');

    Result := Assigned(D3D10CreateDevice) and Assigned(D3D10CreateDeviceAndSwapChain);
    if not Result then
      UnlinkD3D10;
  end
  else
    Result := True;
end;

procedure UnlinkD3D10;
begin
  if LibraryHandle <> 0 then
  begin
    ResetReferences;
    FreeLibrary(LibraryHandle);
    LibraryHandle := 0;
  end;
end;

end.
